//package com.mk.es.demo.config;
//
//import org.elasticsearch.client.RestHighLevelClient;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.elasticsearch.client.ClientConfiguration;
//import org.springframework.data.elasticsearch.client.RestClients;
//import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
//import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
//import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
//
//import java.time.Duration;
//
///**
// * @EnableElasticsearchRepositories 注解可使用 JPA 访问 ES ，basePackages 为 Spring 扫描的包
// * 该段代码配置 Elasticsearch Client ，创建 ElasticsearchRestTemplate 对象
// */
//@Configuration
//@EnableElasticsearchRepositories
//public class ElasticsearchConfiguration extends AbstractElasticsearchConfiguration {
//
//    @Value("${spring.elasticsearch.rest.uris}")
//    private String uris;
//
//    @Override
//    @Bean
//    public RestHighLevelClient elasticsearchClient() {
//
//        final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
//                .connectedTo(uris.split(","))
//                .withConnectTimeout(Duration.ofSeconds(5))
//                .withSocketTimeout(Duration.ofSeconds(30))
//                .build();
//
//        return RestClients.create(clientConfiguration).rest();
//    }
//
//    @Bean("esRestTemplate")
//    public ElasticsearchRestTemplate esRestTemplate() {
//
//        return new ElasticsearchRestTemplate(elasticsearchClient());
//    }
//
//}